home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rectangle.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.0 KB  |  44 lines

  1. // $Id: rectangle.cc 1.2 1997/07/14 04:23:26 dlorre Exp dlorre $
  2. #include <clib/macros.h>
  3. #include "rectangle.h"
  4.  
  5. rectangle::rectangle(short l, short t, short w, short h)
  6. {
  7.     left = MAX(l, short(0)) ;
  8.     top = MAX(t, short(0)) ;
  9.     width = MAX(w, short(0));
  10.     height = MAX(h, short(0)) ;
  11.     minw = maxw = 0 ;
  12.     minh = maxh = 0 ;
  13. }
  14. void rectangle::box(short l, short t, short w, short h)
  15. {
  16.     left = l ;
  17.     top = t ;
  18.     width = w ;
  19.     height = h ;
  20.     if ((left+width) > maxw) maxw = short(left+width) ;
  21.     if ((top+height) > maxh) maxh = short(top+height) ;
  22. }
  23.  
  24. void rectangle::relbox(short dx, short dy, short dw, short dh)
  25. {
  26.     box(dx+left, dy+top, dw+width, dh+height) ;
  27. }
  28.  
  29. void rectangle::move(short dx, short dy) {
  30.     box(dx+left, dy+top, width, height) ;
  31. }
  32.  
  33.  
  34. void rectangle::size(short dw, short dh) {
  35.     box(left, top, dw+width, dh+height) ;
  36. }
  37.  
  38. void rectangle::limits(short wmin, short hmin, short wmax, short hmax) {
  39.     minw = MAX(wmin, short(0)) ;
  40.     minh = MAX(hmin, short(0)) ;
  41.     maxw = MAX(wmax, minw) ;
  42.     maxh = MAX(hmax, minh) ;
  43. }
  44.